package com.swxy.controller;

import com.swxy.pojo.Book;
import com.swxy.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
//解决跨域问题
@CrossOrigin

public class BookController {

    @Autowired
    BookService bookService;

    @RequestMapping("/test")
    public String test(Model model){

        List<Book> bookList = bookService.querySelectAll();


        return "book_list";
    }


    @RequestMapping("/all")
    @ResponseBody
    public List<Book> all(){
        System.out.println("ff");
        List<Book> bookList = bookService.querySelectAll();

        System.out.println(bookList);


        return bookList;
    }



}
